/* 
 * Copyright (C) 2005,2006,2007 MaNGOS <http://www.mangosproject.org/>
 * Copyright (C) 2007 NoxForum.net <http://www.noxforum.net/>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/// \addtogroup u2w
/// @{
/// \file

#ifndef __WOLSOCKET_H
#define __WOLSOCKET_H

#include "WorldPacket.h"
#include "Network/TcpSocket.h"

/// Handle connection with the client software
class WolSocket : public TcpSocket
{
    public:
        WolSocket(ISocketHandler &sh);
        ~WolSocket();

		void encode(unsigned char *password, int len);

		void OnLine(const std::string& line);
		void OnConnect();
        void SendPacket(WorldPacket* packet);
        void Update(time_t diff);
		void SetUsername(char* username) {strncpy(m_username, username, 10);}
		void SetPassword(char* password) {
			strncpy(m_password, password, 10);
			encode((unsigned char*)m_password, strlen(m_password));
		}

    protected:
        void _HandleLANPing(WorldPacket& recvPacket);
		void _HandleJoin(WorldPacket& recvPacket);

	private:
        ZThread::LockedQueue<WorldPacket*,ZThread::FastMutex> _sendQueue;
		
		char m_username[10];
		char m_password[10];
};
#endif
/// @}
